#!/usr/bin/env node 
const Koa = require('koa'),
      Router = require('koa-router'),
      cors = require('koa2-cors'),
      logger = require('koa-logger'),
      loadRouters = require('require-directory'),
      bodyparser = require('koa-bodyparser'),
      koaBody = require('koa-body'),
      path = require('path');
const app = new Koa(),
      router = new Router();

app.use(cors({ origin:'*', method: 'GET,PUT,POST,DELETE' }));
app.use(logger());
app.use(bodyparser({enableTypes: ['json', 'form', 'text']}));
/*
app.use(koaBody({
  multipart: true,
  formidable: {
    uploadDir: path.join(__dirname, './image'),
    keepExtensions: true
  }
}))*/
loadRouters(module, './routes', {visit: (r)=>{
  app.use(r.routes());
}})
app.listen(3333, '0.0.0.0');
